home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacHack 1997
/
MacHack 1997.toast
/
Hacks
/
Hacks ’97
/
Whack-A-Bill
/
source code
/
hidembar.h
< prev
next >
Wrap
Text File
|
1997-06-27
|
2KB
|
90 lines
void HideMenuBar( void );
void ShowMenuBar( void );
Rect menuBarRect;
short menuBarHeight;
RgnHandle originalGrayRgn, newGrayRgn, underBarRgn;
//***********************
void HideMenuBar( void )
{
GDHandle mainScreen;
Rect mainScreenBounds;
RgnHandle mainScreenRgn;
GrafPtr windowPort;
GrafPtr oldPort;
WindowPtr frontWindow;
// get the gdhandle of the main screen which
// is the screen with the menubar
mainScreen = GetMainDevice();
mainScreenBounds = ( *mainScreen )->gdRect;
// get new region encompassing entire screen
// including area under menu bar and corners
mainScreenRgn = NewRgn();
newGrayRgn = NewRgn();
underBarRgn = NewRgn();
RectRgn( mainScreenRgn, &mainScreenBounds );
UnionRgn( mainScreenRgn, originalGrayRgn, newGrayRgn );
DiffRgn( newGrayRgn, originalGrayRgn, underBarRgn );
DisposeRgn( mainScreenRgn );
// Set gray region to entire screen
LMSetGrayRgn( newGrayRgn );
GetPort( &oldPort );
GetWMgrPort( &windowPort );
SetPort( windowPort );
SetClip( newGrayRgn );
// redraw the desktop to draw over the menu bar
PaintOne( nil, newGrayRgn );
// in case any part of a window is covered
// redraw it and recalculate the visible region
frontWindow = FrontWindow();
PaintOne( ( WindowRef )frontWindow, underBarRgn );
PaintBehind( ( WindowRef )frontWindow, underBarRgn );
CalcVis( ( WindowRef )frontWindow );
CalcVisBehind( ( WindowRef )frontWindow, underBarRgn );
// set menu bar height to 0
LMSetMBarHeight( 0 );
// Restore the port
SetPort( oldPort );
}//HideMenuBar
//***********************
void ShowMenuBar( void )
{
WindowPtr frontWindow;
GrafPtr windowPort;
GrafPtr oldPort;
// Reset the menu bar height
LMSetMBarHeight( menuBarHeight );
// Restore the original gray region
LMSetGrayRgn( originalGrayRgn );
frontWindow = FrontWindow();
CalcVis( (GrafPort *)frontWindow );
CalcVisBehind( ( WindowRef )frontWindow, newGrayRgn );
// Reset the clipping regions of the window mgr port
GetPort( &oldPort );
GetWMgrPort( &windowPort );
SetPort( windowPort );
SetClip( newGrayRgn );
SetPort( oldPort );
// Redraw the menu bar
HiliteMenu( 0 );
DrawMenuBar();
}